//package com.lagou.demo.dao.impl;
//
//import com.lagou.demo.dao.AccountDao;
//import com.lagou.demo.pojo.Account;
//import com.lagou.demo.utils.ConnectionUtils;
//import com.lagou.demo.utils.DruidUtils;
//import com.lagou.edu.mvcframework.annotations.LagouAutowired;
//import com.lagou.edu.mvcframework.annotations.LagouRepository;
//
//import java.sql.Connection;
//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//
///**
// * @author 应癫
// */
//@LagouRepository("accountDao")
//public class JdbcAccountDaoImpl implements AccountDao {
//    @LagouAutowired
//    private ConnectionUtils connectionUtils;
//
//
//    public void init() {
//        System.out.println("初始化方法.....");
//    }
//
//    public void destory() {
//        System.out.println("销毁方法......");
//    }
//
//    @Override
//    public boolean queryByName(String name) {
////        //从连接池获取连接
//         Connection con = DruidUtils.getInstance().getConnection();
//        Connection con = connectionUtils.getCurrentThreadConn();
//        String sql = "select * from account where cardNo=?";
//        PreparedStatement preparedStatement = con.prepareStatement(sql);
//        preparedStatement.setString(1, cardNo);
//        ResultSet resultSet = preparedStatement.executeQuery();
//
//        Account account = new Account();
//        while (resultSet.next()) {
//            account.setCardNo(resultSet.getString("cardNo"));
//            account.setName(resultSet.getString("name"));
//            account.setMoney(resultSet.getInt("money"));
//        }
//
//        resultSet.close();
//        preparedStatement.close();
//        //con.close();
//
//        return account;
//        return true;
//    }
//
////    @Override
////    public Account queryAccountByCardNo(String cardNo) throws Exception {
////        //从连接池获取连接
////        // Connection con = DruidUtils.getInstance().getConnection();
////        Connection con = connectionUtils.getCurrentThreadConn();
////        String sql = "select * from account where cardNo=?";
////        PreparedStatement preparedStatement = con.prepareStatement(sql);
////        preparedStatement.setString(1, cardNo);
////        ResultSet resultSet = preparedStatement.executeQuery();
////
////        Account account = new Account();
////        while (resultSet.next()) {
////            account.setCardNo(resultSet.getString("cardNo"));
////            account.setName(resultSet.getString("name"));
////            account.setMoney(resultSet.getInt("money"));
////        }
////
////        resultSet.close();
////        preparedStatement.close();
////        //con.close();
////
////        return account;
////    }
////
////    @Override
////    public int updateAccountByCardNo(Account account) throws Exception {
////
////        // 从连接池获取连接
////        // 改造为：从当前线程当中获取绑定的connection连接
////        //Connection con = DruidUtils.getInstance().getConnection();
////        Connection con = connectionUtils.getCurrentThreadConn();
////        String sql = "update account set money=? where cardNo=?";
////        PreparedStatement preparedStatement = con.prepareStatement(sql);
////        preparedStatement.setInt(1, account.getMoney());
////        preparedStatement.setString(2, account.getCardNo());
////        int i = preparedStatement.executeUpdate();
////
////        preparedStatement.close();
////        //con.close();
////        return i;
////    }
//}
